# File: tkinter_learning.py

from Tkinter import *

class App:

    def __init__(self, master):

        frame = Frame(master)
        frame.pack()

        self.texter = Listbox(frame);
        self.texter.pack(side=TOP);

        self.button = Button(frame, text="QUIT", fg="red", command=master.quit);
        self.button.pack(side=LEFT);

        self.hi_there = Button(frame, text="Hello", command=self.say_hi);
        self.hi_there.pack(side=LEFT);

    def say_hi(self):
        print "hi there, everyone!"
        ##print self.texter.cget("height"), self.texter.cget("width");
        print self.texter.keys();

root = Tk()

def newlistfilefn():
    print "called newlistfilefn!"
def listselectfn():
    print "called listselectfn!"
def addjobfn():
    print "called addjobfn!"
def removejobfn():
    print "called removejobfn!"
def clearlistfn():
    print "called clearlistfn!"
def startlistfn():
    print "called startlistfn!"
def delayedstopfn():
    print "called delayedstopfn!"
def emergencystopfn():
    print "called emergencystopfn!"
def helpaboutfn():
	print "called helpaboutfn!"
# create a menu
menu = Menu(root)
root.config(menu=menu)

<<<<<<< .mine
filemenu = Menu(menu, tearoff=0)
menu.add_cascade(label="File", menu=filemenu)
##filemenu.add_command(label="New", command=callback)
##filemenu.add_command(label="Open...", command=callback)
filemenu.add_command(label="New list", command=newlistfilefn)
filemenu.add_command(label="Open list", command=listselectfn)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=root.quit)
=======

def callback():
    print "called the callback!"
def quitcommand():
    root.quit();
def helpabout():
    print "argh not implemented yet!"
# create a menu
menu = Menu(root)
root.config(menu=menu)
>>>>>>> .r22

<<<<<<< .mine
listmenu = Menu(menu, tearoff=0)
menu.add_cascade(label="List", menu=listmenu)
listmenu.add_command(label="Add job", command=addjobfn)
listmenu.add_command(label="Delete job", command=removejobfn)
listmenu.add_command(label="Clear", command=clearlistfn)
=======
filemenu = Menu(menu, tearoff=0)
menu.add_cascade(label="File", menu=filemenu)
#filemenu.add_command(label="New", command=callback)
#filemenu.add_command(label="Open...", command=callback)
#filemenu.add_separator()
filemenu.add_command(label="Exit", command=quitcommand)
>>>>>>> .r22

<<<<<<< .mine
runnermenu = Menu(menu, tearoff=0)
menu.add_cascade(label="Runner", menu=runnermenu)
runnermenu.add_command(label="Start", command=startlistfn)
runnermenu.add_command(label="Stop after current", command=delayedstopfn)
runnermenu.add_command(label="Stop now", command=emergencystopfn)

helpmenu = Menu(menu, tearoff=0)
menu.add_cascade(label="Help", menu=helpmenu)
helpmenu.add_command(label="About...", command=helpaboutfn)

=======
helpmenu = Menu(menu, tearoff=0)
menu.add_cascade(label="Help", menu=helpmenu)
helpmenu.add_command(label="About...", command=helpabout)


>>>>>>> .r22
### create a toolbar
##toolbar = Frame(root)
##
##b = Button(toolbar, text="new", width=6, command=callback)
##b.pack(side=LEFT, padx=2, pady=2)
##
##b = Button(toolbar, text="open", width=6, command=callback)
##b.pack(side=LEFT, padx=2, pady=2)
##
##toolbar.pack(side=TOP, fill=X)

listbox = Listbox(root);
listbox.insert(END, "a list entry")
for item in ["one", "two", "three", "four"]:
    listbox.insert(END, item)
    listbox.update_idletasks();
listbox.pack(padx=5,pady=5);

def deleteitem():
    print listbox.get(ANCHOR);
    listbox.delete(ANCHOR);

b = Button(root, text="delete", width=6, command=deleteitem)
b.pack(side=LEFT, padx=2, pady=2)

#app = App(root)
root.mainloop()
